import java.util.Scanner;
public class FindGCD {
    public static int findGcd(int m,int n){
        if(m%n==0)return n;
        else{
            return findGcd(n,m%n);
        }
    }
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int m=scan.nextInt();
        int n=scan.nextInt();
        System.out.println(findGcd(m,n));
    }
}
